package com.ytxg.user.controller;

import com.ytxg.api.dto.UserCommentsDtoR;
import com.ytxg.core.dto.RestResp;
import com.ytxg.core.utils.JwtUtils;
import com.ytxg.core.utils.UserHolder;
import com.ytxg.user.dto.UserDtoIn;
import com.ytxg.user.dto.UserInfoRespDto;
import com.ytxg.user.dto.UserLoginRespDto;
import com.ytxg.user.service.UserInfoService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/front/user")
public class UserController {

    @Resource
    private UserInfoService userInfoService;

    @PostMapping("login")
    public RestResp<UserLoginRespDto> login(@RequestBody UserDtoIn userDtoIn){
        RestResp<UserLoginRespDto> login = userInfoService.login(userDtoIn);

        return login;
    }

    @GetMapping
    public RestResp<UserInfoRespDto> getUserInfo(  ){
        RestResp<UserInfoRespDto> userInfo = userInfoService.getUserInfo(UserHolder.getUserId());
        return userInfo;
    }

    @GetMapping("comments")
    public RestResp comments( UserCommentsDtoR userCommentsDtoR){

        RestResp comments = userInfoService.getComments(userCommentsDtoR);
        return comments;
    }
}
